<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@page import="objetos.ForcaBean"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<jsp:useBean id="cadPalavra" scope="request" class="objetos.ForcaBean" />
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Jogo da Forca - Cadastro de Palavra</title>

</head>
<body>
	<h1>Cadastro de Palavra</h1>
	<form id="frmCadPalavra" name="frmCadPalavra" method="post" action="">
		<%
			String var = (String) request.getSession().getAttribute("status");
		%>
		<%
			if (var != null)
		%><%=var%>
		<table>
			<tr>
				<td>Palavra</td>
				<td><input type="text" name="txtPalavra" id="txtPalavra"
					size="50"
					value='<jsp:getProperty property="palavra" name="cadPalavra"/>' /></td>
			</tr>
			<tr>
				<td>Nivel</td>
				<%
					String nivel = cadPalavra.getNivel();
					if (nivel == null) {
						nivel = "";
					}
				%>
				<td><select id="txtNivel" name="txtNivel">
						<option value="" <%if (nivel.equals("")) {%> SELECTED <%}%>>Selecione</option>
						<option value="BASICO" <%if (nivel.equals("BASICO")) {%> SELECTED
							<%}%>>Basico</option>
						<option value="MEDIO" <%if (nivel.equals("MEDIO")) {%> SELECTED
							<%}%>>Medio</option>
						<option value="AVANCADO" <%if (nivel.equals("AVANCADO")) {%>
							SELECTED <%}%>>Avancado</option>
				</select></td>
			</tr>
			<tr>
				<td>Dica 1</td>
				<td><input type="text" name="txtDica1" id="txtDica1" size="50"
					value='<jsp:getProperty property="dica1" name="cadPalavra"/>' /></td>
			</tr>
			<tr>
				<td>Dica 2</td>
				<td><input type="text" name="txtDica2" id="txtDica2" size="50"
					value='<jsp:getProperty property="dica2" name="cadPalavra"/>' /></td>
			</tr>
			<tr>
				<td colspan="2"><input type="button" value="Gravar"
					onClick="javascript:validar('cadastroPalavra')" /></td>
			</tr>
			<tr>
				<td colspan="2"><input type="button" value="Voltar"
					onClick="javascript:voltar('voltarPrincipal')" /></td>
			</tr>
		</table>
	</form>
	<script>
	function validar(paramAcao) {
		var palavra = document.frmCadPalavra.txtPalavra.value;
		var dica1 = document.frmCadPalavra.txtDica1.value;
		var dica2 = document.frmCadPalavra.txtDica2.value;
		var nivel = document.frmCadPalavra.txtNivel.value;
		
		if (palavra != "" && dica1 != "" && dica2 != "" && nivel != "")
		{
			document.frmCadPalavra.action="<%=request.getContextPath()%>/ForcaServlet?acao="+ paramAcao;
			document.frmCadPalavra.submit();
		} else

		if (palavra == "") {
			alert("Favor preencher PALAVRA !");
		} else if (nivel == "") {
			alert("Favor escolher NIVEL !");
		} else if (dica1 == "") {
			alert("Favor preencher DICA 1 !");
		} else if (dica2 == "") {
			alert("Favor preencher DICA 2 !");
		}

	}
	
	function voltar(paramAcao) {
		document.frmCadPalavra.action="<%=request.getContextPath()%>/ForcaServlet?acao="+ paramAcao;
		document.frmCadPalavra.submit();
	}
</script>
</body>
</html>